<template>
	<view class="business">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				设备管理
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop" :style="{marginTop: pHeight + tHeight + 'px'}"></view>
		<view class="fenlei clearfix">
			<view class="list fl" @click="topage('/subpackageA/equipment/all')">
				<image :src="baseUrl + '/wximage/sbtubiao1.png'"></image>
				<view class="name">全部设备</view>
			</view>
			<view class="list fl" @click="topage('/subpackageA/equipment/xiabo')">
				<image :src="baseUrl + '/wximage/sbtubiao2.png'"></image>
				<view class="name">设备下拨</view>
			</view>
			<view class="list fl" @click="kaifang">
				<image :src="baseUrl + '/wximage/sbtubiao3.png'"></image>
				<view class="name">设备回拨</view>
			</view>
			<view class="list fl" @click="topage('/subpackageA/equipment/saomaweihu')">
				<image :src="baseUrl + '/wximage/sbtubiao4.png'"></image>
				<view class="name">设备维护</view>
			</view>
			<view class="list fl" @click="topage('/subpackageA/equipment/huishou')">
				<image :src="baseUrl + '/wximage/sbtubiao5.png'"></image>
				<view class="name">设备回收</view>
			</view>
			<view class="list fl" @click="kaifang">
				<image :src="baseUrl + '/wximage/sbtubiao6.png'"></image>
				<view class="name">回拨确认</view>
			</view>
			<view class="list fl" @click="topage('/subpackageA/equipment/weixiu')">
				<image :src="baseUrl + '/wximage/sbtubiao7.png'"></image>
				<view class="name">设备维修</view>
			</view>
			<view class="list fl" @click="topage('/subpackageA/equipment/weixiurecord')">
				<image :src="baseUrl + '/wximage/sbtubiao8.png'"></image>
				<view class="name">维修记录</view>
			</view>
		</view>
		<view class="tongji">
			<view class="heads clearfix">
				<view class="left fl">
					<image :src="baseUrl + '/wximage/hktubiao.png'"></image>
					<view class="name">我的</view>
				</view>
			</view>
			<view class="shuju clearfix">
				<view class="liebiao">
					<view class="shuzi">{{mylist.kucun}}</view>
					<view class="names">库存(台)</view>
				</view>
				<view class="liebiao">
					<view class="shuzi">{{mylist.chargersum}}</view>
					<view class="names">已安装(台)</view>
				</view>
				<view class="liebiao">
					<view class="shuzi">{{mylist.linesum}}</view>
					<view class="names">在线(台)</view>
				</view>
				<view class="liebiao">
					<view class="shuzi">{{mylist.nolinesum}}</view>
					<view class="names">离线(台)</view>
				</view>
			</view>
		</view>
		<view class="tongji">
			<view class="heads clearfix">
				<view class="left fl">
					<image :src="baseUrl + '/wximage/hktubiao.png'"></image>
					<view class="name">下级代理</view>
				</view>
			</view>
			<view class="shuju clearfix">
				<view class="liebiao">
					<view class="shuzi">{{xialist.kucun}}</view>
					<view class="names">库存(台)</view>
				</view>
				<view class="liebiao">
					<view class="shuzi">{{xialist.chargersum}}</view>
					<view class="names">已安装(台)</view>
				</view>
				<view class="liebiao">
					<view class="shuzi">{{xialist.linesum}}</view>
					<view class="names">在线(台)</view>
				</view>
				<view class="liebiao">
					<view class="shuzi">{{xialist.nolinesum}}</view>
					<view class="names">离线(台)</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				list: [1],
				agentid: uni.getStorageSync('agent_id'),
				mylist: {},
				xialist: {}
			}
		},
		onLoad() {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			this.getDeviceNum();
		},
		methods: {
			getDeviceNum(){
				this.request({
					url: '/wxdevice/devicecount',
					data: {agentid:this.agentid},
					method: "GET"
				}).then(res => {
					if (res.data.code == 200) {
						// if(res.data.data!=null){
						// 	this.bussinessList = this.bussinessList.concat(res.data.data);
						// }
						this.mylist = res.data.data.mylist;
						this.xialist = res.data.data.xialist;
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			topage(url){
				uni.navigateTo({
					url
				})
			},
			kaifang(){
				uni.showToast({
					title: '暂未开放',
					icon: 'none'
				})
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.business {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;
		}
		
		.fenlei{
			width: 90%;
			margin: 0 auto;
			background: linear-gradient(90deg, #F9F9FF, #FDFDFF);
			border-radius: 26rpx;
			margin-top: -280rpx;
			padding-bottom: 20rpx;
			
			.list{
				width: 25%;
				text-align: center;
				float: left;
		
				image{
					width: 80rpx;
					height: 80rpx;
					margin-top: 20rpx;
				}
				
				.name{
					font-size: 24rpx;
					color: #333333;
				}
			}
		}
		
		.tongji{
			width: 90%;
			margin: 0 auto;
			z-index: 70;
			margin-top: 40rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
			
			.heads{
				width: 100%;
				padding: 24rpx 20rpx 0;
				box-sizing: border-box;
				
				.left{
					
					image{
						float: left;
						width: 40rpx;
						height: 40rpx;
						margin-top: -6rpx;
					}
					
					.name{
						font-size: 28rpx;
						color: #333333;
						float: left;
					}
				}
				
				.right{
					
					image{
						float: left;
						width: 40rpx;
						height: 40rpx;
						margin-top: -6rpx;
					}
					
					.name{
						font-size: 28rpx;
						color: #368BF8;
						float: left;
					}
				}
			}
			
			.shuju {
				width: 100%;
				padding: 30rpx 26rpx;
				box-sizing: border-box;
				border-radius: 16rpx;
			
				.liebiao {
					width: 25%;
					text-align: center;
					float: left;
			
					.shuzi {
						font-size: 40rpx;
						color: #333333;
						font-weight: 700;
						margin-bottom: 10rpx;
					}
			
					.names {
						font-size: 24rpx;
						color: #333333;
					}
				}
			}
		}
	}
</style>